package com.huonan.designpattern.piplie.dts;

import com.huonan.utils.SftpUtil;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description TODO
 * @Author lxp
 * @Date 2023/2/3 上午11:10
 * @Version V1.0
 **/
@Slf4j
public class FetchHandler implements Handler<String,List<FileEntity>> {


    public FetchHandler(String[] args) {
    }

    @Override
    public List<FileEntity> process(String input) {
        log.info("FetchHandler");
        List<FileEntity> fileList = new ArrayList<>();
            String datePath = "20230419";
            String preSrc = String.format("/bailian/regulation/%s/dianping/dianping.com/",datePath);
            List<String> fileNames = SftpUtil.lsFiles(preSrc);
            for (String file : fileNames) {
                String fileUrl = preSrc+file;
                FileEntity.builder()
                        .status(0)
                        .fileUrl(fileUrl)
                        .id(1);//TODO 自增
            }

        return fileList;
    }
}
